<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@include file="/includes/taglibs.jsp"%>
<%@page import="com.feib.soeasy.util.UserUtil"%>

<c:choose>
    <c:when test="${null != actionBean.resultPayer}">
        <div id="modifyPayerViewDiv">
            <stripes:form id="payerModifyFrom" beanclass="com.feib.soeasy.action.Soez1015ActionBean" 
                method="post">        
                <table id="PayerTable">
                    <c:if test="${actionBean.payerTempMessage ne null }">
                        <tr>
                            <th>注意</th>
                            <td colspan="3">
                                <c:out value="${actionBean.payerTempMessage }"></c:out>                    
                            </td>
                        </tr>
                    </c:if> 
                    <%  if (UserUtil.isBankGroup()) {%>
                    <tr>
                        <th>業者代號<span id="mustKeyInStar">**</span></th>
                        <td>
                        	<c:out value="${actionBean.resultPayer.group.groupNo }" />
                        	<stripes:hidden id="groupNo" name="resultPayer.group.groupNo" />
                        </td>
                        <th>業者名稱</th>
                        <td>
                        	<c:out value="${actionBean.resultPayer.group.groupName }" />                               
                        </td>                                 
                    </tr>
                    <%
                        } else {
                    %>   
                        	<input type="hidden" id="groupNo" name="<%=UserUtil.getUserGroup().getGroupNo() %>" />
                    <% }%>
                    <tr>
                        <th>客戶編號<span id="mustKeyInStar">**</span></th>
                        <td>
                        	<stripes:hidden id="payerNo" name="resultPayer.payerNo" />
                        	<c:out value="${actionBean.resultPayer.payerNo }" />
                        </td> 
                        <th>姓名</th>
                        <td>
                            <stripes:text id="payerName" name="resultPayer.payerName" size="15" maxlength="20" />
                        </td>                       
                    </tr>                 
                    <tr>
                        <th>E-MAIL</th>
                        <td colspan="3">
                            <stripes:text id="payerEmail" name="resultPayer.payerEmail" size="30" maxlength="30" />
                        </td>                        
                    </tr>                
                    <tr>
                        <th>電話</th>
                        <td>
                            <stripes:text id="payerTelNo" name="resultPayer.payerTelNo" size="15" maxlength="20" />
                        </td>
                        <th>手機號碼</th>
                        <td>
                            <stripes:text id="payerCellNo" name="resultPayer.payerCellNo" size="15" maxlength="10" />
                        </td>                        
                    </tr>  
                    <tr>
                        <th>坪數</th>
                        <td>
                            <stripes:text id="levelGround" name="resultPayer.levelGround" size="15" maxlength="5" />
                        </td>
                        <th>車位數</th>
                        <td>
                            <stripes:text id="parkingCount" name="resultPayer.parkingCount" size="15" maxlength="2" />
                        </td>                        
                    </tr>  
                    
                    <tr>
                        <th>門牌號碼</th>
                        <td colspan="3">
                            <stripes:text id="houseNo" name="resultPayer.houseNo" size="50" maxlength="50" />                         
                        </td>
                    </tr>    
                    <tr>
                        <th>聯絡地址</th>
                        <td colspan="3">
                            <stripes:text id="payerAddress" name="resultPayer.payerAddress" size="50" maxlength="50" />                         
                        </td>
                    </tr> 
                    <tr>
                        <th>備註</th>
                        <td colspan="3">
                            <stripes:text id="payerMemo" name="resultPayer.payerMemo" size="50" maxlength="50" />                         
                        </td>
                    </tr>                                                                             
                    <tr>
                        <td colspan="4" class="queryFunction" align="center">
                            <stripes:button id="doModifyBtn" name="doModifyBtn" value="確認" class="formBtn"/>
                            <stripes:button id="doDeleteBtn" name="doDeleteBtn" value="刪除" class="formBtn"/>
                        	<stripes:button id="printBtn4" name="printBtn4" value="列印" class="formBtn"/>
                            <stripes:button id="doCloseBtn" name="doCloseBtn" value="離開" class="formBtn"/>
                        </td>
                    </tr>                   
                </table>
            </stripes:form>    
        </div>
        <div id="modifyPayerHiddenFormDiv" style="display: none; ">
            <stripes:form id="modifyPayerHiddenFrom" beanclass="com.feib.soeasy.action.Soez1015ActionBean" 
                method="post" onsubmit="javascript: return false;">         
                <input type="hidden" id="hidden2.resultPayer.payerPk" name="resultPayer.payerPk" value="<c:out value='${actionBean.resultPayer.payerPk}'/>"/>
                <input type="hidden" id="hidden2.tempResult" name="tempResult" value="<c:out value='${actionBean.tempResult}'/>"/>
                <input type="hidden" id="hidden2.resultPayer.groupNo" name="resultPayer.group.groupNo"/>  
                <input type="hidden" id="hidden2.resultPayer.payerNo" name="resultPayer.payerNo"/>
                <input type="hidden" id="hidden2.resultPayer.payerName" name="resultPayer.payerName"/>                    
                <input type="hidden" id="hidden2.resultPayer.payerEmail" name="resultPayer.payerEmail"/>
                <input type="hidden" id="hidden2.resultPayer.payerTelNo" name="resultPayer.payerTelNo"/>                
                <input type="hidden" id="hidden2.resultPayer.payerCellNo" name="resultPayer.payerCellNo"/>
                <input type="hidden" id="hidden2.resultPayer.levelGround" name="resultPayer.levelGround"/>
                <input type="hidden" id="hidden2.resultPayer.parkingCount" name="resultPayer.parkingCount"/>
                <input type="hidden" id="hidden2.resultPayer.houseNo" name="resultPayer.houseNo"/>
                <input type="hidden" id="hidden2.resultPayer.payerAddress" name="resultPayer.payerAddress"/>
                <input type="hidden" id="hidden2.resultPayer.payerMemo" name="resultPayer.payerMemo"/>
                <input type="hidden" id="method3" name="doPayerModifyAction"/>
            </stripes:form>
        </div>
        <div id="modifyPayerMsgDiv" style="display: none; ">
        </div> 
        <div id="deletePayerHiddenFormDiv" style="display: none; ">
            <stripes:form id="deletePayerHiddenFrom" beanclass="com.feib.soeasy.action.Soez1015ActionBean" 
                method="post" onsubmit="javascript: return false;">         
                <input type="hidden" id="hidden4.resultPayer.payerPk" name="resultPayer.payerPk" value="<c:out value='${actionBean.resultPayer.payerPk}'/>"/>                
                <input type="hidden" id="hidden4.tempResult" name="tempResult" value="<c:out value='${actionBean.tempResult}'/>"/>
                <input type="hidden" id="method5" name="doPayerDeleteAction"/>
            </stripes:form>
        </div>
        <div id="deletePayerMsgDiv" style="display: none; ">
        </div> 
        <script type="text/javascript">
        <!--
            $(document).ready(function() {
            	
            	$('#printBtn4').click(function() {
    				divPrint('modifyPayerViewDiv');
    			});
                
                $("#doCloseBtn").click(function() {
                    $("#payerDiv").dialog("close");
                });
                
                $("#doModifyBtn").click(function() {
                    
                    var groupNo = $('#groupNo').val();
                    var payerNo = $('#payerNo').val();
                    var payerName = $('#payerName').val();
                    var payerEmail = $('#payerEmail').val();
                    var payerTelNo = $('#payerTelNo').val();                    
                    var payerCellNo = $('#payerCellNo').val();
                    var levelGround = $('#levelGround').val();
                    var parkingCount = $('#parkingCount').val();
                    var houseNo = $('#houseNo').val();
                    var payerAddress = $('#payerAddress').val();
                    var payerMemo = $('#payerMemo').val();
                    
                    $('#hidden2\\.resultPayer\\.groupNo').val(groupNo);
                    $('#hidden2\\.resultPayer\\.payerNo').val(payerNo);
                    $('#hidden2\\.resultPayer\\.payerName').val(payerName);
                    $('#hidden2\\.resultPayer\\.payerEmail').val(payerEmail);
                    $('#hidden2\\.resultPayer\\.payerTelNo').val(payerTelNo);                    
                    $('#hidden2\\.resultPayer\\.payerCellNo').val(payerCellNo);
                    $('#hidden2\\.resultPayer\\.levelGround').val(levelGround);
                    $('#hidden2\\.resultPayer\\.parkingCount').val(parkingCount);   
                    $('#hidden2\\.resultPayer\\.houseNo').val(houseNo); 
                    $('#hidden2\\.resultPayer\\.payerAddress').val(payerAddress); 
                    $('#hidden2\\.resultPayer\\.payerMemo').val(payerMemo); 
                    
                    var errorMessage = '';
                    if (payerName == '') 
                        errorMessage = errorMessage + '姓名 是必要欄位<br/>';
                    
                    
                    if (null == payerEmail || 0 == payerEmail.length){
        				
        			}
        			else if (! verifyEmail(payerEmail)){
        				errorMessage = errorMessage + "E-MAIL 格式錯誤<br/>";
        			}
                    
                    if (0 != errorMessage.length){
        				$("#ajaxErrorMessageDiv").html(errorMessage);
        				$("#ajaxErrorMessageDiv" ).dialog({  
        					title:'請修正下列錯誤' 
        					,width: 300
        					, resizable: false
        					, modal: true
        					, buttons: {
        						Ok: function() {
        							$( this ).dialog( "close" );
        						}
        					}
        				});
        				return false;
        			}                  
                    
                    waitingDialog({});
                    $.ajax({url : "<c:url value='/ajax/Soez1015.action'/>",
                        async : false,
                        type : 'POST',
                        data : $("#modifyPayerHiddenFrom").serialize(),
                        dataType : 'html',
                        success : function(data, textStatus, XMLHttpRequest){
                                $("#modifyPayerViewDiv").hide();
                                $("#modifyPayerMsgDiv" ).html(data);
                                $("#modifyPayerMsgDiv").show();
                            },
                        error : function(XMLHttpRequest, textStatus, errorThrown){
                            $("#ajaxErrorMessageDiv").html('系統發生錯誤，請聯絡管理員');
                            $("#ajaxErrorMessageDiv" ).dialog({  
                                title:'系統錯誤' 
                                ,width: 600
                                , resizable: false
                                , modal: true
                                , buttons: {
                                    Ok: function() {
                                        $( this ).dialog( "close" );
                                    }
                                }
                            });
                            },
                        complete: function(XMLHttpRequest, textStatus){
                            closeWaitingDialog();
                        }
                    });
                });            
            });        
        
        $(document).ready(function() {
            $("#doDeleteBtn").click(function() {
            	var answer = confirm('是否確定刪除 ?');
            	
            	if (!answer)
            		return ;
                waitingDialog({});
                $.ajax({url : "<c:url value='/ajax/Soez1015.action'/>",
                    async : false,
                    type : 'POST',
                    data : $("#deletePayerHiddenFrom").serialize(),
                    dataType : 'html',
                    success : function(data, textStatus, XMLHttpRequest){
                            $("#modifyPayerViewDiv").hide();
                            $("#deletePayerMsgDiv" ).html(data);
                            $("#deletePayerMsgDiv").show();
                        },
                    error : function(XMLHttpRequest, textStatus, errorThrown){
                        $("#ajaxErrorMessageDiv").html('系統發生錯誤，請聯絡管理員');
                        $("#ajaxErrorMessageDiv" ).dialog({  
                            title:'系統錯誤' 
                            ,width: 600
                            , resizable: false
                            , modal: true
                            , buttons: {
                                Ok: function() {
                                    $( this ).dialog( "close" );
                                }
                            }
                        });
                        },
                    complete: function(XMLHttpRequest, textStatus){
                        closeWaitingDialog();
                    }
                });
            });
        });    
        //-->
        </script>        
    </c:when>
    <c:otherwise>
            查無資料
        <script type="text/javascript">
        <!--
        $(document).ready(function() {
            $( "#payerDiv" ).dialog({  title:'繳款人資料' ,width: 600, resizable: false, modal: true  });
        });
        //-->
        </script>
    </c:otherwise>
</c:choose>    